package common.splitpage.sql;

import common.splitpage.Condition;
import common.splitpage.PageInfo;

public class OraclePageSql implements IPageSql {

	private Condition condition;
	private String sql;
	
	public OraclePageSql(PageInfo pageInfo) {
		this.condition = pageInfo.getCondition();
		this.sql = condition.getSql();
	}

	public String getPageSql() {
		int startRow = condition.getStartRow();//从1算起
		int endRow = condition.getEndRow();
		int pageRowCount = condition.getPageRowCount();
		sql = sql.replace("from", ",rownum num from");
		return "select * from (" + sql + ") where num between " + startRow + " and " + endRow;
	}

}
